#ifndef eval_h
#define eval_h

#if HAVE_CONFIG_H
# include <config.h>
#endif

#include <assert.h>


#define MAX_MATE_DEPTH 500
#define MATE_VAL(depth) \
  (assert(depth >= 0 && depth <= MAX_MATE_DEPTH), 32000 - (depth))
#define IS_MATE_VAL(score) \
  (((score) >= MATE_VAL(MAX_MATE_DEPTH)) && ((score) <= MATE_VAL(0)))
#define MATE_DEPTH(score) \
  (assert(IS_MATE_VAL(score)), MATE_VAL(0) - score)
#define INF_VAL 32767


extern const int pieces_values[7];

struct position_t;  // forward declaration


typedef struct evaluation_t
{
  /* Scores for the side to move.  Each score is reported twice (one
     for each phase). */
  int phase;  // 0-256
  int material[2];
  int pawns[2];
  int knights[2];
  int bishops[2];
  int rooks[2];
  int queens[2];
  int kings[2];
  int phase_total[2];
  int total;
} evaluation_t;


void eval_init();
int eval(const struct position_t* pos, int alpha, int beta);
void eval_detail(const struct position_t* pos,
		 evaluation_t* ev);

void eval_reset_max_positional_value();
int eval_max_positional_value();
void eval_update_max_positional_value();

void eval_set_random(int r);

// Return the size (in megabytes) of the pawn table.
int eval_pawn_table_size();


#endif  // eval_t
